<%-- 
    Document   : index
    Created on : Apr 21, 2012, 7:01:58 PM
    Author     : TANGQUOCTUAN
--%>
<%@page import="java.util.ArrayList"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tunga Restaurant</title>
        <script type="text/javascript">
            function check(){
                var user = document.getElementById("user");
                var re = /^\w{6,20}$/;
                if(user.value.length==0){
                    alert("This field is required");
                    f.txtUserRig.focus();
                    return false;
                }

                if(re.test(user.value)==false){
                    alert("Username must be least at 6 - 20 character");
                    f.txtUserRig.focus();
                    return false;
                }
               
                var pass = document.getElementById("pass");
                if(pass.value.length==0){
                    alert("This field is required");
                    f.txtPassRig.focus();
                    return false;
                }

                if(re.test(pass.value)==false){
                    alert("Password must be least at 6 - 20 character");
                    f.txtPassRig.focus();
                    return false;
                }

                var cpass = document.getElementById("cpass");
                if((cpass.value)!=(pass.value)){
                    alert("Confirm password not compatible or can not blank");
                    f.txtCPassRig.focus();
                    return false;
                }

                var re_name = /^\w[A-Za-z\s]*\w$/;
                var fname = document.getElementById("fname");
                if(fname.value.length==0){
                    alert("This field is required");
                    f.txtFnameRig.focus();
                    return false;
                }

                if(re_name.test(fname.value)==false){
                    alert("First name must be character");
                    f.txtFnameRig.focus();
                    return false;
                }

                var lname = document.getElementById("lname");
                if(lname.value.length==0){
                    alert("This field is required");
                    f.txtLnameRig.focus();
                    return false;
                }

                if(re_name.test(lname.value)==false){
                    alert("Last name must be character");
                    f.txtLnameRig.focus();
                    return false;
                }

                var re_email=/^[A-Za-z][A-Za-z0-9_.-]+@[A-Za-z]+\.[A-Za-z]{2,4}(\.[A-Za-z]{2,4})*$/;
                var email = document.getElementById("email");
                if(email.value.length==0){
                    alert("This field is required");
                    f.txtEmailRig.focus();
                    return false;
                }

                if(re_email.test(email.value)==false){
                    alert("Email must follow form xxx@xxx.xxx");
                    f.txtEmailRig.focus();
                    return false;
                }

                var resphone=/^[\d]{1,20}$/;
                var phone = document.getElementById("phone");
                if(phone.value.length==0){
                    alert("This field is required");
                    f.txtPhoneRig.focus();
                    return false;
                }

                if(resphone.test(phone.value)==false){
                    alert("Phone must be numberic, max 20 numberic");
                    f.txtPhoneRig.focus();
                    return false;
                }

                var re_address=/^\w[\w\s]+\w$/;
                var address = document.getElementById("address");
                if((address.value.trim()).length==0){
                    alert("This field is required");
                    f.txtAddressRig.focus();
                    return false;
                }
				
                if(re_address.test(address.value)==false){
                    alert("Address character only");
                    f.txtAddressRig.focus();
                    return false;
                }
                return true;
            }
        </script>
        <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <center>
            <c:set var="session" value="${sessionScope.user}"/>
            <div class="outer">
                <!--Header end-->
                <div id="rc1"></div>
                <div id="bg">
                    <div class="toplinks"><a href="ContactUs.jsp">Contact us</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="initShowFood?action=Food">Food</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerTables?action=Table">Table</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerRooms?action=Room">Room</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="registration.jsp">Register</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="login.jsp">Login</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="index.jsp">Home Page</a></div>
                </div>
                <div id="rc2"></div>
                <div id="header">
                    <div class="name">Tunga Restaurant</div>
                    <div class="tag">The best restaurant in the world</div>
                </div>
                <!--Top nav end-->
                <div style="clear:left"></div>
                <div id="outer2">
                    <div id="left-nav">
                        <div class="leftlinks">
                            <span class="heading">Quick Links</span>
                            <ul>
                                <li><a href="index.jsp">Home Page </a></li>
                                <li><a href="ControllerRooms?action=Room">Room</a></li>
                                <li><a href="ControllerTables?action=Table">Table</a></li>
                                <li><a href="initShowFood?action=Food">Food</a></li>
                                <c:if test="${not empty session}">
                                    <li><a href="ControllerRooms?action=BookRoom">Book Room</a></li>
                                    <li><a href="ControllerTables?action=BookTable">Book Table </a></li>                                   
                                    <li><a href="addToCart.jsp">Shopping Cart</a></li>
                                </c:if>
                                <li><a href="ContactUs.jsp">Contact Us </a></li>
                            </ul>
                        </div>
                    </div><div class="inner_copy"><div class="inner_copy">All <a href="http://www.magentothemesworld.com" title="Best Magento Templates">premium Magento themes</a> at Magentothemesworld.com!</div></div>
                    <div id="content">
                        <span class="heading">Registration Form </span>
                        <div id="main">
                            <form action="ControllerCustomer" method="POST" name="f" onsubmit="return check();">
                                <table border="0" align="center">
                                    <tbody>
                                        <tr>
                                            <td>Choose UserName:</td>
                                            <td><input type="text" name="txtUserRig" id="user"/></td>
                                        </tr>
                                        <tr>
                                            <td>Create Password:</td>
                                            <td><input type="password" name="txtPassRig" id="pass"/></td>
                                        </tr>
                                        <tr>
                                            <td>Confirm Password:</td>
                                            <td><input type="password" name="txtCPassRig" id="cpass"/></td>
                                        </tr>
                                        <tr>
                                            <td>First Name:</td>
                                            <td><input type="text" name="txtFnameRig" id="fname"/></td>
                                        </tr>
                                        <tr>
                                            <td>Last Name:</td>
                                            <td><input type="text" name="txtLnameRig" id="lname"/></td>
                                        </tr>
                                        <tr>
                                            <td>Email:</td>
                                            <td><input type="text" name="txtEmailRig" id="email"/></td>
                                        </tr>
                                        <tr>
                                            <td>Phone:</td>
                                            <td><input type="text" name="txtPhoneRig" id="phone"/></td>
                                        </tr>
                                        <tr>
                                            <td>Address:</td>
                                            <td><textarea name="txtAddressRig" id="address" rows="10" cols="30"></textarea></td>
                                        </tr>
                                        <tr>
                                            <td></td>
                                            <td><input type="submit" value="Register" name="action" /> <input type="reset" value="Reset" /></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                    <div style="clear:left"></div>
                </div>
                <!--Bottom part-->
                <div id="bottom">
                    <div id="footer"><div class="fcenter">GROUP02-F5-10-1009-S1</div></div>
                </div>
            </div>
        </center>
    </body>
</html>
